<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>站长后台</title>
    <link rel="stylesheet" href="../../static/ditch/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="../../static/ditch/css/index.css"/>
    <link rel="stylesheet" href="../../static/ditch/css/jquery.pagination.css"/>
    <script src="../../static/ditch/js/jquery-1.12.3.js"></script>
    <script src="../../static/ditch/layui/layui.js"></script>
    <script src="../../static/ditch/js/less.min.js"></script>
    <script src="../../static/ditch/js/jquery.pagination.min.js"></script>
    <!--<script src="js/plugins/pace/pace.min.js"></script>-->
</head>
<style>
    .content img {
        width: 3rem;
    }

    img:hover {
        transform: scale(2, 2);
        transition: .5s transform;
    }
</style>

<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
    {% include "/ditch/left.html" %}
    <div class="layui-body">
        <div id="box" class="fl">
            <div class="content">
                <h3>推广数据</h3>
                <form method="get" action="/ditch/channel_return.html">
                    <div class="search">
                        <label>渠道：</label><input value="{% if res['ditch'] is not none and res['ditch'] != "None" %}{{ res['ditch'] }}{% endif %}" class="name" name="ditch" type="text" placeholder="请输入渠道名"/>
                        <label style="margin-left: 1%;">日期：</label><input value="{% if res['time'] is not none and res['time'] != "None" %}{{ res['time'] }}{% endif %}" name="time" type="text" class="demo-input" placeholder="请选择日期"id="test1">
                        <button class="s_button">搜索</button>
                    </div>
                </form>
                <table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tbody>
                    <tr>
                        <th width="10%">日期</th>
                        <th width="10%">渠道号</th>
                        <th width="10%">点击数</th>
                        <th width="10%">安装数</th>
                        <th width="10%">注册数</th>
                        <th width="10%">金额</th>
                    </tr>
                    </tbody>
                    {% if res['data'] is not none %}
                    {% for data in res['data'] %}
                    <tr>
                        <td>{{ data.day }}</td>
                        <td>{{ data.ditch }}</td>
                        <td>{{ data.clicks }}</td>
                        <td>{{ data.num }}</td>
                        <td>{{ data.users_num }}</td>
                        <td>{{ data.price }}</td>
                    </tr>
                    {% endfor %}
                    {% endif %}
                </table>

            </div>
            <div id="pagination1" class="page fr" style="margin-right: 1%;">
                <div class="ui-pagination-container">
                    <a id = "ssy"href="/ditch/channel_return.html?page=1" class="ui-pagination-page-item" data-current="1">首页</a>
		                    <a id = "sy"href="/ditch/channel_return.html?page={{ res['page'] - 1 }}{% if res['status'] is not none%}&status={{ res['status'] }}{% endif %}{% if res['kind'] is not none%}&kind={{ res['kind'] }}{% endif %}{% if res['kind_id'] is not none%}&kind_id={{ res['kind_id'] }}{% endif %}" class="ui-pagination-page-item" data-current="1">上一页</a>
                            {% for i in range(res['page'] - 2, res['page'] + 3) %}
		                    <a href="/ditch/channel_return.html?page={{ i }}" class="ui-pagination-page-item{% if res['page'] == i %} active{% endif %}"id = "{{ i }}" style="display:none;">{{ i }}</a>
		                    {% endfor %}
                            <a id = "xy"href="/ditch/channel_return.html?page={{ res['page'] + 1 }}" class="ui-pagination-page-item" data-current="3">下一页</a>
		                    <a id = "wy"href="/ditch/channel_return.html?page={{ res['max_page'] }}" class="ui-pagination-page-item" data-current="12">尾页</a>
                </div>
            </div>
        </div>

    </div>
</div>

<script>
    //JavaScript代码区域
    layui.use('element', function () {
        var element = layui.element;

    });
</script>
</body>

</html>
<script src="../../static/ditch/laydate/laydate.js"></script>
<script>
    layui.use('laydate', function () {
        var laydate = layui.laydate;

        //常规用法
        laydate.render({
            elem: '#test1'
        });

        laydate.render({
            elem: '#test2'
        });
    })
    $(function () {
        var zx = {{ res['page'] }};
        var zd = {{ res['max_page'] }};
        if (zx<=1){
            $('#sy').remove();
            $('#ssy').remove();
        }
        if(zx >= zd){
            $('#xy').remove();
            $('#wy').remove();
        }
        for(var i = 1;i<=zd;i++){
            if($('#'+i).text()<=zx+2 && $('#'+i).text()>=zx-2){
                $('#'+i).show();
            }
            if($('#'+i).text()== zx){
                $('#'+i).attr("href","javascript:;");
            }
        }
    })


</script>
